package com.example.xiaoming.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.example.xiaoming.R;

/**
 * 版权：wxj公司 版权所有
 *
 * @author ：wxj
 * 版本：1.01080478
 * 创建日期：2021/6/30 if
 * 包名：com.example.xiaoming
 * 类名：xiaoming
 * 加密：switch
 * 描述：
 */
public class DialogActivity extends Activity implements View.OnClickListener {
    private final static String TAG=DialogActivity.class.getSimpleName();
    public final static int DIALOG_RESULT_CODE = 0xf3;
    public final static String AGREE = "agree";
    public final static String DIALOG = "dialog";
    private TextView tv_agree;
    private TextView tv_disagree;
    private TextView tv_text;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e(TAG,"onCreate");
        setContentView(R.layout.activity_dialog);
        tv_agree = findViewById(R.id.tv_agree);
        tv_agree.setOnClickListener(this);
        tv_disagree = findViewById(R.id.tv_disagree);
        tv_disagree.setOnClickListener(this);
        tv_text=findViewById(R.id.tv_text);
        tv_text.setText(getIntent().getStringExtra(DIALOG));
    }

    @Override
    public void onClick(View v) {
        Intent intent=new Intent();
        switch (v.getId()) {
            case R.id.tv_agree:
                intent.putExtra(AGREE,true);
                setResult(DIALOG_RESULT_CODE,intent);
                finish();
                break;
            case R.id.tv_disagree:
                intent.putExtra(AGREE,false);
                setResult(DIALOG_RESULT_CODE,intent);
                finish();
                break;
        }
    }
}
